
CROSS_PREFIX := aarch64-elf-
CC := $(CROSS_PREFIX)gcc
AS := $(CROSS_PREFIX)as
LD := $(CROSS_PREFIX)ld
OBJDUMP := $(CROSS_PREFIX)objdump
# LD_FLAGS := -mno-strict-align
# LD_FLAGS += -mabi=lp64
# C_FLAGS := -O2
# LD_FLAGS := -L/CORE/CAD/arm-dev/aarch-gcc/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-elf/aarch64-elf/libc/usr/lib/ -lc
# LD_FLAGS += -lgcc 
# 

# C_FLAGS += -D

objs := start.o
objs += syscall.o
objs += uart/pl01x.o
objs += init.o
objs += test.o

test.elf: $(objs)
	$(CC)  -e _entry_start -Ttext 0x2000000 $^ -o $@ -v

	# $(CC)  $(LD_FLAGS) -T link.lds $^ -o $@ 
	# $(LD) -T link.lds $^   $(LD_FLAGS) -o $@ 
	$(OBJDUMP) -d $@ > $@.asm

clean:
	rm *.o *.elf

%.o: %.c
	$(CC) $(C_FLAGS) -c $^ -o $@

%.o: %.s
	$(CC) $(C_FLAGS) -c $^ -o $@
